package org.grow.enter.filter;

import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * @Author: xwg
 * @CreateDate: 2021/9/8
 */

@Service
//@Component
public class First implements Filter {

    @Override
    public void doFilter(ServletRequest req,
                         ServletResponse res,
                         FilterChain filterChain) throws IOException, ServletException {
//       http  servletRequest
        HttpServletRequest request = (HttpServletRequest) req;
//        http://localhost:8080/aaa/vvv
//        request.getRequestURL();
//        /aaa/vvv
        String requestURI = request.getRequestURI();
        System.out.println("第一过滤器拦截到："+requestURI);
        filterChain.doFilter(req, res);
        System.out.println("第一过滤器结束");

    }
}
